Computer and methods for solving math functions

ABSTRACT

Computers and methods for performing mathematical functions are disclosed. An embodiment of a computer includes an operations level and a driver level. The operations level performs mathematical operations. The driver level includes a first lookup table and a second lookup table, wherein the first lookup table includes first data for calculating at least one mathematical function using a first level of accuracy. The second lookup table includes second data for calculating the at least one mathematical function using a second level of accuracy, wherein the first level of accuracy is greater than the second level of accuracy. A driver executes either the first data or the second data depending on a selected level of accuracy.

BACKGROUND

Some computers are used to perform complex math functions, such as cubed root and hyperbolic trigonometric functions. These complex math functions require many cycles to complete, which is time consuming and uses a lot of energy. The long time required to calculate complex functions creates a problem when the computer needs to calculate many complex functions in a short period. For example, if the computer is used to guide an aircraft, the computer may need to calculate pitch, yaw, and roll from a plurality of sensors using complex functions.

The high energy demand required to calculate complex functions becomes an issue with computers that are operating from limited power supplies, such as batteries. The calculation of the complex functions requires many cycles, which draws heavily on the batteries. In addition, the high energy demand creates heat, which may interfere with the operation of the computer.

SUMMARY

Computers and methods for performing mathematical functions are disclosed. An embodiment of a computer includes an operations level and a driver level. The operations level performs mathematical operations. The driver level includes a first lookup table and a second lookup table, wherein the first lookup table includes first data for calculating at least one mathematical function using a first level of accuracy. The second lookup table includes second data for calculating the at least one mathematical function using a second level of accuracy, wherein the first level of accuracy is greater than the second level of accuracy. A driver executes the data from the first lookup table or the second lookup table and sends instructions to the operations level.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a high level block diagram of an embodiment of a computer for solving complex math functions.

FIG. 2 is a table illustrating examples of math functions that are calculated by the driver level of the computer of FIG. 1.

FIG. 3 is a table illustrating examples of complex functions that are calculated by the computer of FIG. 1.

FIG. 4 is a flow diagram of the computer of FIG. 1 when it is calculating equations using basic operations.

FIG. 5 is a flow diagram of the computer of FIG. 1 when it is calculating the function sin(x).

FIG. 6 is a flowchart showing the operation of the computer of FIG. 1.

DETAILED DESCRIPTION

Computer architectures, sometimes referred to herein simply as computers, and methods of calculating mathematical functions are described herein. The computers and methods provide for calculating mathematical functions using different options. In the embodiments described herein, a first option calculates complex functions using high accuracy. In this option, many instructions have to be performed to calculate a single complex function, which uses a lot of energy. A second option calculates complex functions using lower accuracy. This second option does not require as many instructions as the high accuracy option, so the complex function can be solved faster, using uses less energy. High accuracy calculations require more instructions and therefore typically require more time to complete than low accuracy calculations. Low accuracy calculations use less energy than high accuracy calculations and may be used in situations where energy preservation is important, such as when the energy comes from a battery-powered source. These situations include situations where a lot of calculations are required on a battery-powered device. The low accuracy option uses less energy than the high accuracy option, so there is less drain on the battery.

In some embodiments, complex functions are broken down into instructions that use simpler functions. For example, the calculation of a hyperbolic sine may be performed by solving exponent functions and division and subtraction operations. In the embodiments described herein, the solutions to the exponent functions are stored in lookup tables. Thus, the computers do not need to calculate the hyperbolic sine function directly. Rather, the computers only need to solve the exponent functions and the subtraction and division operations, which are less time consuming and energy consuming than direct calculations of hyperbolic sine.

Reference is made to FIG. 1, which is a block diagram of a computer 100. The computer 100 is sometimes referred to as computer architecture. In the embodiment of FIG. 1, the computer 100 includes three levels, an instruction level 102, a driver level 104, and an operations level 106. The instruction level 102 receives instructions to solve or calculate math operations and functions, including complex math functions. In some embodiments, the instruction level 102 also receives a number or value for which the function is to be solved. In addition, the instruction level 102 receives information as to whether the function is to be solved using high accuracy or low accuracy.

Examples of the complex mathematical functions include hyperbolic trigonometric functions, cubed root, and some power functions, such as 2^(x). The instruction level 102 includes a main controller 110, which is sometimes referred to simply as a controller 110, and memory 112. The controller 110 has an input 114 that receives the above-described functions and numbers. The controller 110 also has an output 116 that outputs the result of the calculation performed by the computer 100. The instruction level 102 may have different embodiments. For example, in some embodiments, the instruction level 102 is or includes an application specific instruction processor (ASIP).

The controller 110 has, or has access to, memory 112 by way of a port 113 on the controller 110 and a port 115 on the memory 112. The memory 112 stores code for solving the complex functions. In some embodiments, the controller 110 calls the memory 112 for instructions to solve a complex function, such as cosh(x). The memory 112 has the instructions stored for solving cosh(x), which, in the embodiments described herein is shown by equation (1) as follows:

$\begin{matrix} {{\cosh(x)} = \frac{e^{x} - e^{- x}}{2}} & {{Equation}\mspace{14mu}(1)} \end{matrix}$

The instruction level 102 communicates with the driver level 104 by way of ports 118 and 119 to solve some functions. In the example of equation (1), the driver level solves the exponent (exp) functions by using lookup tables as described in greater detail below. In some embodiments, the driver level 104 is a state machine. The driver level 104 includes a driver 120 and lookup tables 122. The driver 120 communicates with the controller 110 to receive the instructions from the memory 112 when the computer 100 is solving complex functions, such as equation (1). In some situations, simpler functions are solved that do not require the instructions stored in the memory 112, however, the driver 120 may still receive the instructions for solving these simpler functions from the controller 110.

The driver 120 communicates with the lookup tables 122. There are a plurality of lookup tables 122 that contain information or instructions for different baseline math functions as described below. In the embodiment of FIG. 1, there are two lookup tables, a first lookup table 124, which is sometimes referred to as the LUT 124, and a second lookup table 126, which is sometimes referred to as the LUT 126. In the embodiment of FIG. 1, the LUT 124 stores information or instructions for calculating functions using high accuracy functions and the LUT 126 stores information or instructions for calculating functions using low accuracy, which use less energy. For example, the LUT 126 may return 32 bit data and the LUT 124 may return 38 bit data for higher accuracy calculations. The results from a high accuracy calculation may include one bit for the sign, eight bits for the exponent, and 29 bits for the mantissa. The driver 120 communicates with the LUT 124 by way of ports 123 and 125. The driver 120 communicates with the LUT 126 by way of ports 128 and 129. In some embodiments, the lookup tables 122 contain coefficients for math function approximations and constants for math function implementation. In some embodiments, the lookup tables 124 and 126 contain instructions regarding solving the functions stored in the lookup tables 124 and 126, wherein the lookup table 124 typically requires more instructions to complete the more complex functions that the lookup table 126.

As an example of the different lookup tables, the exponential (exp) function is used to solve the cosh(x) function using a fifteenth order Taylor series in the high accuracy solution and a third order polynomial curve fitting in the low accuracy solution. Polynomial curve fitting is sometimes referred to as polyfit. In the embodiment described herein, the relatively simple baseline functions accessed by the driver 120 and stored in the lookup tables 122 are shown in FIG. 2. The complex functions performed by the computer 100 are shown in FIG. 3 and are performed using the baseline functions, which include sine, cosine, tangent, arctangent, exp, natural log, and square root functions. As shown in FIG. 2, the baseline functions may be solved using either lookup table 124 or 126 depending on the required accuracy and/or energy usage.

The operations level 106 is sometimes referred to as being at the bottom level of the computer 100. In some embodiments, the operations level 106 is a hardware accelerator that performs basic floating-point operations such as addition, subtraction, and multiplication. The operations level 106 includes an operation module 130 that performs the operations. The operation module 130 communicates with the driver 120 by way of ports 132 and 134. The operation module 130 also communicates with the controller 110 by way of ports 136 and 138. In the embodiment of FIG. 1, the operation module 130 is able to output data directly to the controller 110 using ports 136 and 138 without the data being processed by the driver 120.

As stated above, the operations level 106 performs low level operations using the operation module 130. In the embodiments described herein, the operation module 130 performs the following operations:

-   -   floating-point addition and subtraction;     -   fixed-point addition and subtraction;     -   floating-point multiplication;     -   floating-point comparison;     -   floating-point to integer casting, which is used to zero-out the         fractional part in a floating point number;     -   absolute (x) for a floating point number;     -   shifting an operand to the right by 1 bit, which is required for         inverse square root and reciprocal operations;     -   addition of exponents of two floating point numbers, which is         required for exp operations;     -   masking exponents to 127, which is required for natural log         operations;     -   converting exponents to floating point numbers, which is         required for natural log operations;     -   negating computation outputs; and     -   rounding results in internal format (29 bit mantissa) and         standard format (23 bit mantissa).

Based on the functions that can be performed in the driver level 104 and the operations that can be performed in the operations level 106, the computer 100 is capable of solving a plurality of complex functions. An example embodiment of the complex functions that are performed by the computer 100 is shown by the table in FIG. 3. The table in FIG. 3 also shows the derivations or derived functions that are used to solve the complex functions. The derived functions and their associated operations are performed by the driver 120 in the driver level 104 and the operation module 130 in the operations level 106. In other embodiments, instructions for solving complex functions other than those shown in FIG. 3 are coded into the instruction level 102. In summary, the computer 100 receives an instruction to solve a complex function as shown in FIG. 3. The computer uses the derived functions of FIG. 3 to solve the complex function. The derived functions of FIG. 3 have baseline functions and operations that are solved using the lookup tables shown in FIG. 2 and the operations in the operations level 106.

Having described the components of the computer 100, its operation will now be described using several different examples. Reference is made to FIG. 4, which shows the flow through the computer 100 when the data and instructions at the input 114 indicate that a math operation using the operations in the operating level 106 is to be calculated. The data and/or instructions received at the input 114 are analyzed by the main controller 110. In this embodiment, the data is two numbers and an instruction is to add these two numbers. The controller 110 sends instructions to the operation module 130 to perform the addition operation. As shown in FIG. 4, the instructions and/or data passes through the driver 120. In some embodiments, the data and/or instructions bypass the driver 120. In other embodiments, the driver 120 analyzes the instructions and/or data from the controller 110 and passes the instructions and/or data to the operation module 130. In some embodiments, the driver 120 puts the instructions and data in a format that the operation module 130 is able to readily execute.

The operation module 130 executes the instruction by performing the operation. In this embodiment, two numbers are added together. As shown in FIG. 4, the result is transferred directly to the controller 110, which sends the result to the output 116. In some embodiments, the controller 110 sends instructions to the operation module 130 that directs the result calculated by the operation module 130 be sent directly to the controller 110 so as to bypass the driver 120. Bypassing the driver 120 enables the computer 100 to perform the operation faster than embodiments where the result is passed to the driver 120.

A second embodiment of the operation of the computer 100 is shown in FIG. 5 where the computer 100 is determining sin(x). The computer 100 receives instructions and data, wherein the instructions are to perform a sine function and the data is the value of (x). The instructions can include data as to whether the sine function is to be performed using high accuracy or low accuracy. As described above, low energy calculations are the same as low accuracy calculations. Referring to the table of FIG. 2, the high accuracy sine function is calculated using a sixteenth order Taylor series and the low accuracy sine function is calculated using a third order polyfit.

The controller 110 analyzes the instructions and determines that the function is performed at the driver level 104. Instructions are then sent to the driver 120 to perform the sine function. The instructions also indicate whether high accuracy or low accuracy is to be used. The driver 120 analyses the instructions and accesses the proper lookup table. If high accuracy is required, the LUT 124 is addressed and the sin(x) function is calculated using a sixteenth order Taylor series. If low accuracy or low energy is required, the LUT 126 is addressed and the sin(x) function is solved using the third order polyfit. In using either the Taylor series or the polyfit, the driver 120 needs to access operations, such as addition, in the operation module 130. In some embodiments, the driver 120 transmits values to the operation module 130 to be added with instructions that the sum is to be transmitted to the controller 110. The driver 120 also sends a signal to the controller 110 indicating that the result of the sin(x) function will be output by the operation module 130. When the result is received from the operation module 130, it is output by way of the output 116 of the controller 110.

In a third example, which is related to FIG. 4, the computer 100 receives instructions to solve a complex function, such as the hyperbolic cosine of x, or cosh(x). As with the previous example, the instructions may include whether the cosh(x) function is to be calculated using high or low accuracy. The controller 110 reads the instructions and determines that the function is a complex function and needs to be solved using the code stored in the memory 112. The code includes instructions for solving the function using the derived function of cosh(x) as shown in FIG. 3. The controller 110 executes the code related to solving for cosh(x), which is shown in equation (1). The instructions require the driver 120 to execute the functions of e^(x) and e^(−x). The driver 120 uses the operation module 130 to perform the addition and division required from equation (1). When the operation module 130 has performed the final operation, the result is sent to the controller 110 where it is output to the output 116.

The operation of the computer 100 solving a function is shown by the flowchart 200 of FIG. 6. In block 202, the function to be solved is received. In block 204, information is received as to whether the function is to be solved using high accuracy or low accuracy. In some embodiments, the information in blocks 202 and 204 is received in one step. In step 206 instructions for solving the function using at least one derived math function are executed. For example, a derived math function as shown in FIG. 3 is used to solve a complex function. In step 208, the at least one derived math function is solved using data stored in a first lookup table in response to the function being solved using high accuracy. In step 210, the at least one derived math function is solved using data stored in a second lookup table in response to the function being solved using low accuracy. The lookup tables may include instructions for solving the baseline functions stored in the lookup tables as described above.

The computer 100 provides for high accuracy and low accuracy solutions to complex math functions. In some embodiments, such as vehicle sensors, high accuracy calculations may be required. The LUT 124 stores the information necessary for the high accuracy calculations. Other embodiments do not need the high accuracy and may need to conserve energy. For example, some battery operated devices may operate using the low accuracy information in the LUT 126, which conserves energy.

While illustrative and presently preferred embodiments of harvesting devices have been described in detail herein, it is to be understood that the inventive concepts may be otherwise variously embodied and employed and that the appended claims are intended to be construed to include such variations except insofar as limited by the prior art. 

What is claimed is:
 1. A computer comprising: an operations level that performs mathematical operations; and a driver level comprising: a first lookup table, wherein the first lookup table includes first data for calculating at least one mathematical function using a first level of accuracy; and a second lookup table, wherein the second lookup table includes second data for calculating the at least one mathematical function using a second level of accuracy, wherein the first level of accuracy is greater than the second level of accuracy; and a driver that executes the data from the first lookup table and the second lookup table, and wherein the driver sends instructions to the operations level; wherein executing data in the second lookup table for solving the at least one function uses less energy than executing data in the first lookup table for solving the at least one function.
 2. A computer for performing mathematical functions, the computer comprising: an operations level; a driver level; and an instruction level; the operations level performing basic math operations; the driver level including: a first lookup table, wherein the first lookup table includes first data for calculating at least one mathematical function using a first level of accuracy; and a second lookup table, wherein the second lookup table includes second data for calculating the at least one mathematical function using a second level of accuracy, wherein the first level of accuracy is greater than the second level of accuracy; and a driver that executes the data from the first lookup table and the second lookup table, and wherein the driver sends instructions to the operation level and receives instructions from the instruction level; the instruction level including: a memory that stores instructions for solving complex functions; a controller that executes the instructions stored in the memory and transmits instructions to the driver; wherein the controller receives instructions indicating whether high accuracy or low energy is to be used in solving the function and wherein the controller instructs the driver to access the first lookup table when the function is to be solved using high accuracy and wherein the controller instructs the driver to access the second lookup table when the function is to be solved using low energy.
 3. A method for reducing energy consumption of a computer to solve math functions, the method comprising: receiving a math function to be solved; receiving information as to whether the math function is to be solved using high energy or low energy; executing instructions for solving the math function using at least one derived math function; executing the derived math functions using data stored in a first lookup table if the math function is to be solved using high energy; and executing the derived math functions using data stored in a second lookup table if the math function is to be solved using low energy. 